package model.map{
	import flash.display.DisplayObject;
	import flash.display.Sprite;
	import flash.text.TextField;
	import model.GlobalTextFormat;
	import flash.events.*;
	
	public class ButtonAsset extends Sprite
	{
		[Bindable]
		[Embed('assets/component.swf', symbol='InfoButton')]
		private static var infoButton:Class;
		
		private var button:DisplayObject;
		private var label:TextField;
		
		public function ButtonAsset()
		{
			button = new infoButton();
			label = new TextField();		
			
			if(!contains(button))
			addChild(button);
		}
		
		public function set text(value:String):void
		{
			if(!contains(label))
			{
				label.autoSize = "center";
				label.selectable = false;
				label.multiline = true; 
				addChild(label);
			}
			
			label.text = value;
			label.x = 0;
			label.y = 1;
			label.width = button.width;
			label.height = button.height;
			label.setTextFormat(GlobalTextFormat.buttonAssetStyle);
		}
		
		override public function set width(value:Number):void
		{
			button.width = value;
			label.width = value;
		}
		
		override public function get width():Number
		{
			return button.width;
		}
		
		override public function set height(value:Number):void
		{
			button.height = value;
			label.height = value;
		}
		
		override public function get height():Number
		{
			return button.height;
		}
	}
}